﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BibMan.util {
    public sealed class WriteOnce<T> {
        private T value;
        private bool hasValue;
        public override string ToString() {
            return Convert.ToString(value);
        }
        public bool Assigned {
            get {
                return hasValue;
            }
        }
        public T Value {
            get {
                return value;
            }
            set {
                if (hasValue) throw new InvalidOperationException("Value already set");
                this.value = value;
                this.hasValue = true;
            }
        }

        //public static implicit operator T(WriteOnce<T> value) { return value.Value; }
        
    }
}
